from selenium import webdriver
from selenium.webdriver.common.by import By

import time

from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()

driver.get("https://so.gushiwen.cn/user/login.aspx")

driver.execute_script("window.scrollTo(0,1000)")
time.sleep(3)
driver.execute_script("window.scrollTo(0,0)")

time.sleep(2)
driver.get_screenshot_as_file("test.png")
print("拍照结束")





# 根据ID 去获取 用户名 密码 登录按钮等 标签
driver.find_element_by_id("email").send_keys("3120318294@qq.com")

driver.find_element_by_id("pwd").send_keys("wsj123456")

time.sleep(10)

driver.find_element_by_id("denglu").click()

# 访问搜索元素
search_ele = driver.find_element_by_id("txtKey")
search_ele.send_keys("江雪")

time.sleep(2)
# 输入一个回车键
search_ele.send_keys(Keys.ENTER)


# 收藏
driver.find_element(By.XPATH, "//div[@class='shoucang']/img").click()


time.sleep(2)
# 点击我的 跳转到 我的页面
driver.find_element(By.XPATH, "//div[@class='son1']/a[6]").click()

# 找到 我们所有的收藏，然后点击第一个

time.sleep(2)
driver.find_element(By.XPATH, "//div[@class='sons']/div[1]/a").click()



